package com.systar.activity.parse;

import org.junit.Assert;
import org.junit.Test;

import com.castsoftware.java.FileExplorer;
import com.systar.activity.monitor.ActivitySource;
import com.systar.activity.state.FileActivity;

public class ParserFactoryTest
{

	@Test
	public void testTxtLog()
	{
		ActivitySource source = new ActivitySource(null, "SRC1", "c:/LOGS");
		FileActivity activity = new FileActivity(source, FileExplorer.getInstance().getFile("c:/LOGS/CAST_Log.txt"));
		FileParser parser = ParserFactory.getParser(activity, null);
		Assert.assertNotNull("Parser expected", parser);
		Assert.assertTrue("TxtLogFileParser expected", parser instanceof TxtLogFileParser);
	}

	@Test
	public void testXSessionLog()
	{
		ActivitySource source = new ActivitySource(null, "SRC1", "c:/LOGS");
		FileActivity activity = new FileActivity(source, FileExplorer.getInstance().getFile("c:/LOGS/Session_Log.xsession"));
		FileParser parser = ParserFactory.getParser(activity, null);
		Assert.assertNotNull("Parser expected", parser);
		Assert.assertTrue("SessionFileParser expected", parser instanceof SessionFileParser);
	}

	@Test
	public void testUnknownLog()
	{
		ActivitySource source = new ActivitySource(null, "SRC1", "c:/LOGS");
		FileActivity activity = new FileActivity(source, FileExplorer.getInstance().getFile("c:/LOGS/Log.unknown"));
		FileParser parser = ParserFactory.getParser(activity, null);
		Assert.assertNull("Parser unexpected", parser);
	}

}
